
import { createRouter, createWebHistory } from 'vue-router';

const routes = [
  {
    path: '/',
    name:'connect',
    component: () => import('../views/Connect/index.vue'),
    meta: {
      title: '云眼智慧可视化平台'
    },
    children: [
      {
        path: 'Build',
        alias: '',
        name: 'Build',
        component: () => import('../views/Outside/index.vue')
      },
      {
        path: 'Park',
        name: 'Park',
        component: () => import('../views/Inside/index.vue')
      }
    ]
  },
  {
    path: '/home',
    component: () => import('../views/Home/index.vue'),
    meta: {
      title: 'HomeView'
    }
  },
  {
    path: "/:catchAll(.*)",
    component: () => import('../views/errors-view/index.vue'),
    meta: {
      title: '404View'
    }
  }
]

const router = createRouter({
  strict: true,
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
});

let isRoutesGenerated = false; // 添加一个标志位，用来判断是否已经生成了动态路由



router.beforeEach((to, from, next) => {
  window.document.title = to.meta.title || 'vite vue3';
  next()
})


export default router;